import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserCardGoodsVO, UserCardGoodsForm, UserCardGoodsQuery } from '@/api/order/userCardGoods/types';

/**
 * 查询名片产品列表
 * @param query
 * @returns {*}
 */

export const listUserCardGoods = (query?: UserCardGoodsQuery): AxiosPromise<UserCardGoodsVO[]> => {
  return request({
    url: '/order/userCardGoods/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询名片产品详细
 * @param id
 */
export const getUserCardGoods = (id: string | number): AxiosPromise<UserCardGoodsVO> => {
  return request({
    url: '/order/userCardGoods/' + id,
    method: 'get'
  });
};

/**
 * 新增名片产品
 * @param data
 */
export const addUserCardGoods = (data: UserCardGoodsForm) => {
  return request({
    url: '/order/userCardGoods',
    method: 'post',
    data: data
  });
};

/**
 * 修改名片产品
 * @param data
 */
export const updateUserCardGoods = (data: UserCardGoodsForm) => {
  return request({
    url: '/order/userCardGoods',
    method: 'put',
    data: data
  });
};

/**
 * 删除名片产品
 * @param id
 */
export const delUserCardGoods = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/userCardGoods/' + id,
    method: 'delete'
  });
};

export default {
  list: listUserCardGoods,
  get: getUserCardGoods,
  add: addUserCardGoods,
  update: updateUserCardGoods,
  del: delUserCardGoods,
}